<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * This file is part of the PEAR Services_RickProof package.
 *
 * PHP version 5
 *
 * LICENSE: This source file is subject to the MIT license that is available
 * through the world-wide-web at the following URI:
 * http://opensource.org/licenses/mit-license.php
 *
 * @category  Services 
 * @package   Services_RickProof
 * @author    David JEAN LOUIS <izimobil@gmail.com>
 * @copyright 2008 David JEAN LOUIS
 * @license   http://opensource.org/licenses/mit-license.php MIT License 
 * @version   CVS: $Id$
 * @link      http://pear.php.net/package/Services_RickProof
 * @since     File available since release 0.1.0
 * @filesource
 */

/**
 * Result returned by Services_RickProof::check() method.
 *
 * <code>
 * $result = new Services_RickProof_Result(10, 'Extreme Risk');
 * echo $result . "\n";
 * $result = new Services_RickProof_Result();
 * echo $result . "\n";
 * // expects:
 * // Extreme Risk (level: 10)
 * // Unknown
 * </code>
 *
 * @category  Services
 * @package   Services_RickProof
 * @author    David JEAN LOUIS <izimobil@gmail.com>
 * @copyright 2008 David JEAN LOUIS
 * @license   http://opensource.org/licenses/mit-license.php MIT License 
 * @version   Release: @package_version@
 * @link      http://pear.php.net/package/Services_RickProof
 * @since     Class available since release 0.1.0
 * @see       Services_RickProof::check()
 */
class Services_RickProof_Result
{
    // properties {{{

    /**
     * The level of the response.
     *
     * @var int $level the response level
     * @access public
     */
    public $level = 0;

    /**
     * The message of the response.
     *
     * @var string $level the response message
     * @access public
     */
    public $message = null;

    // }}}
    // __construct() {{{

    /**
     * Constructor.
     *
     * @param int    $level   the response level
     * @param string $message the response message
     *
     * @return void
     * @access public
     */
    public function __construct($level = 0, $message = null)
    {
        $this->level   = $level;
        $this->message = $message;
    }

    // }}}
    // __toString() {{{

    /**
     * Return the string representation of the response.
     *
     * @return string
     * @access public
     */
    public function __toString()
    {
        if ($this->message !== null) {
            return $this->message . ' (level: ' . $this->level . ')';
        }
        return 'Unknown';
    }

    // }}}
}
